import {createSlice} from '@reduxjs/toolkit';
import axios from 'axios';
const billStore = createSlice({
    name: 'bill',
    initialState: {
        bills: [],
    },
    reducers: {
        //新增账单
        addBill: (state, action) => {
            state.bills.push(action.payload);
        },
    },
});


export const {addBill} = billStore.actions;

const getBillList=()=>{
    return async (dispatch) =>{
       const result = await axios.get('http://localhost:8080/s4/financialRecords/queryFinancialRecords');
       dispatch(addBill(result.data));
    }
}
export {getBillList}
export default billStore.reducer;